package com.example.liuke.guangguang.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.liuke.guangguang.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liuke on 2018/3/26.
 */

public class myrecyAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context mContext;
    private List<String> mydate= new ArrayList<>();

    public myrecyAdapter(Context context, @LayoutRes int layoutResId, @Nullable List<String> data) {
        super(layoutResId, data);
        mContext = context;
        mydate=data;
    }

    @Override
    protected void convert(BaseViewHolder helper, String commentData) {
        Glide.with(mContext).load(commentData).into((ImageView) helper.getView(R.id.recyimag));
    }

    public void remove(int position){
        mydate.remove(position);
        notifyItemRemoved(position);
        notifyItemRangeChanged(position, mydate.size());
    }

    public void add(int position){
        mydate.add(position, "http://d.hiphotos.baidu.com/image/h%3D300/sign=615ad02161224f4a4899751339f69044/b3b7d0a20cf431ad184ee53e4736acaf2edd981d.jpg");
        notifyItemInserted(position);
        notifyItemRangeChanged(position, mydate.size());
    }
}

